//package com.leyou.redis;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.server.ServerWebExchange;
//import reactor.core.publisher.Mono;
//
//@Configuration
//public class RateLimitConfig {
//    //定义一个KeyResolver
//    @Bean
//    public KeyResolver ipKeyResolver() {
//        return new KeyResolver() {
//            @Override
//            public Mono<String> resolve(ServerWebExchange exchange) {
//                return Mono.just(exchange.getRequest().getRemoteAddress().getHostName());
//            }
//        };
//        // JDK8 的Lambda写法：
//        // return exchange -> Mono.just(exchange.getRequest().getRemoteAddress().getHostName());
//    }
//}